angular.module('Controller')
.directive('nrHomeMobile',[()->
    return {
        restrict:'E'
        replace:true
        templateUrl:'templates/home-mobile/home-mobile.html'
        controller:'homeMobileCtrl'
    }
])

.controller 'homeMobileCtrl',($scope,$localStorage)->
    swiper=undefined
    loadSwiper=()->
        swiper = new Swiper('.swiper-container', {
            pagination: '.swiper-pagination'
            paginationClickable: false
            autoHeight: true
            direction: 'vertical'
            onInit: (swiper)->
                swiperAnimateCache(swiper)
                swiperAnimate(swiper)
            onSlideChangeEnd: (swiper)->
                console.log "onSlideChangeEnd"
                swiperAnimate(swiper)
        });
        $('a.back-to-top').click(()->
            if swiper
                swiper.slideTo(0, 1000, true)
        )
    _.defer(()->
        loadSwiper()
    )
